package com.system.connect.springboot_flowers.service.impl;

import cn.hutool.crypto.digest.MD5;
import com.system.connect.springboot_flowers.entity.Admins;
import com.system.connect.springboot_flowers.dto.UsersDto;
import com.system.connect.springboot_flowers.mapper.AdminsMapper;
import com.system.connect.springboot_flowers.service.IAdminsService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 管理员表 服务实现类
 * </p>
 *
 * @author yang
 * @since 2025-01-13
 */
@Service
public class AdminsServiceImpl extends ServiceImpl<AdminsMapper, Admins> implements IAdminsService {

    @Override
    public void register(UsersDto usersDto) {
        //新建到数据库
        Admins users = new Admins();
        users.setUsername(usersDto.getUsername());
        users.setState(false);
        //密码MD5加密
        String password = MD5.create().digestHex(usersDto.getPassword());
        users.setPasswordHash(password);
        users.setEmali(usersDto.getEmail());
        save(users);
    }
}
